<?php
/**
 * Created by PhpStorm.
 * User: zhaozhanyin
 * Date: 2020/12/3
 * Time: 13:20
 */

namespace app\api\controller;


class Webhook
{
    public function giteeSync()
    {
        $local = '/var/www/tp6';
        $request = file_get_contents('php://input');
        $password = '609327';
        if(empty($request)){
            die('request is empty');
        }
        $data = json_decode($request,true);
        if($data['password'] != $password){
            die('password is error');
        }
        echo shell_exec("cd {$local} && git pull origin master 2>&1");
        die('done ' . date('Y-m-d H:i:s', time()));
    }
}
